<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<link rel="stylesheet" type="text/css" href="../../../Themes/default/easyui.css">
		<link rel="stylesheet" type="text/css" href="../../../Themes/gray/window.css">
		<link rel="stylesheet" type="text/css" href="../../../CSS/demo.css">
		<link rel="stylesheet" type="text/css" href="../../../CSS/common.css">
		<link rel="stylesheet" type="text/css" href="../../../Themes/icon.css">

	</head>

	<body style="padding: 0px">
		<div style="width: 400px;">
			<form id="ff" method="post">
				<table cellpadding="3" class="displaytable" style="margin: 30px;">
					<tr>
						<td width="35%">
							<h id="star">* </h>区域类型</td>
						<td width="65%">
							<input class="easyui-combobox" style="width:100%;" data-options="required:'true'" id="input_REGION_TYPE" type="text" name="REGION_TYPE" />
						</td>
					</tr>
					<tr>
						<td>
							<h id="star">* </h>区域名称</td>
						<td>
							<input class="easyui-combobox" style="width:100%;" type="text" id="input_REGION_NAME" name="REGION_NAME" data-options="required:true" />
						</td>
					</tr>
					<tr>
						<td>
							<h id="star">* </h>区域门牌号</td>
						<td>
							<input class="easyui-combobox" style="width:100%;" type="text" id="input_HOUSE_NUMBER" name="HOUSE_NUMBER" data-options="required:true" />
						</td>
					</tr>
					<tr>
						<td>
							<h id="star">* </h>卡证名称</td>
						<td>
							<input class="easyui-combobox" id="input_NAME" style="width: 100%;" type="text" name="NAME" />
						</td>
					</tr>
					<tr>
						<td width="35%">
							<h id="star">* </h>卡证编号</td>
						<td>
							<input class="easyui-textbox" style="width:100%;" type="text" id="input_CARD_NO" name="CARD_NO" data-options="required:true" />
						</td>
					</tr>
					<tr class="hiddentr">
						<td>商铺ID</td>
						<td>
							<input style="width:100%" class="easyui-textbox" id="input_BOOST_ID" name="BOOST_ID"></input>
						</td>
					</tr>
					<tr class="hiddentr">
						<td>ID</td>
						<td>
							<input style="width:100%" class="easyui-textbox" id="input_ID" name="ID"></input>
						</td>

					</tr>
				</table>
				<div class="submit_button" style="margin-left: 50px;">
					<a class="easyui-linkbutton" onclick="save()" style="width: 100px;"> 保存</a>
					<a class="easyui-linkbutton" onclick="cls()" style="width: 100px;margin-left: 10px;">清空 </a>
				</div>
			</form>
		</div>
		<div id="dlg" class="easyui-dialog" closed="true" style="width:560px;height:400px;padding:10px">
			<iframe id="ifrmEdit" height="100%" width="100%" frameborder="0" scrolling="no"></iframe>
		</div>
	</body>

	<script type="text/javascript" src="../../../JS/jquery.min.js"></script>
	<script type="text/javascript" src="../../../JS/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="../../../JS/common.js"></script>
	<script type="text/javascript" src="../../../JS/MarketShareFunction/MarketShareFunction.js"></script>
	<script type="text/javascript" src="../../../JS/easyui-lang-zh_CN.js"></script>
	<script type="text/javascript">
		var AddDialog;
		var id = getID();
		$(document).ready(function(){
			if(id != AddFlag) {
				loadRemote();
			}
		});
		iniREGIONTYPE();

		$('#input_NAME').combobox({
			valueField: 'NAME',
			textField: 'NAME',
			panelHeight: 'auto',
			method: 'get',
			mode: 'remote',
			url: RemoteLinkAddress + "/market/card/listall.do",
		});

		function save() {
			var isValid = $("#ff").form('validate');
			if(!isValid) {
				$.messager.alert("警告", "有必填项没有填写");
				return;
			}
			SaveData();
		}

		function loadRemote() {
			$('#ff').form('load', RemoteLinkAddress + '/market/boostcard/findbyid.do?ID=' + id);
		}

		function cls() {
			$('#ff').form('reset');
		}

		function SaveData() {
			var _url = '';
			data = $('#ff').serialize();
			if(id == AddFlag) {
				_url = RemoteLinkAddress + "/market/boostcard/save.do";
				data = data.replace("&ID=", ""); //在新增保存的时候不需要传入ID值
			} else {
				_url = RemoteLinkAddress + "/market/boostcard/update.do";
			}

			$.post(_url, data,
				function(result) {
					if(result.msg == "success") {
						var parentLocation;
						parentLocation = searchParent("BoothCardList.html");
						parentLocation.dialogClose();
						$.messager.alert({ // show error message
							title: '成功',
							msg: '添加成功'
						});
					} else {
						$.messager.alert({ // show error message
							title: '错误',
							msg: "输入的数据已存在数据库"
						});
					}
				},
				'json');
		}
	</script>

</html>